package com.ssrs.platform.code;

import com.ssrs.framework.extend.annotation.ExtendItem;
import com.ssrs.platform.FixedCodeType;
import com.ssrs.platform.PlatformPlugin;
import com.ssrs.platform.extend.CodeService;
import com.ssrs.platform.util.PlatformUtil;

/**
 * 是或否
 *
 * @author ssrs
 */
@ExtendItem(
		plugin = PlatformPlugin.class,
		extendService = CodeService.class,
		description = "是或否代码项"
)
public class YesOrNoNumber extends FixedCodeType {
	public static final String CODETYPE = "YesOrNoNumber";

	public static final String YES = "1";
	public static final String NO = "0";

	public YesOrNoNumber() {
		super(CODETYPE, "是或否(数字)", false, false);
		addFixedItem(YES, "是", null);
		addFixedItem(NO, "否", null);
	}

	public static boolean isYes(String str) {
		return YES.equals(str);
	}

	public static boolean isNo(String str) {
		return !isYes(str);
	}

	public static String getName(String code) {
		return PlatformUtil.getCodeMap(CODETYPE).getStr(code);
	}
}
